<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:display="http://www.w3.org/1999/xhtml"
      xmlns:div.display="http://www.w3.org/1999/xhtml" xmlns:row.display="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>creditInfo</title>

    <!-- Bootstrap Core CSS -->
    <link th:href="@{/vendor/bootstrap/css/bootstrap.min.css}"
          href="../../static/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <link th:href="@{/vendor/metisMenu/metisMenu.min.css}" rel="stylesheet">

    <link th:href="@{/vendor/datatables/css/jquery.dataTables.min.css}"
          href="../../static/vendor/datatables/css/jquery.dataTables.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link th:href="@{/dist/css/sb-admin-2.css}" rel="stylesheet">

    <!-- Custom Fonts -->
    <link th:href="@{/vendor/font-awesome/css/font-awesome.min.css}" rel="stylesheet" type="text/css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>


<!-- Bootstrap Core JavaScript -->
    <script th:src="@{/vendor/jquery/jquery.min.js}" src="../../static/vendor/jquery/jquery.min.js"></script>

    <script th:src="@{/vendor/bootstrap/js/bootstrap.min.js}"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script th:src="@{/vendor/metisMenu/metisMenu.min.js}"></script>

    <!-- Custom Theme JavaScript -->
    <script th:src="@{/dist/js/sb-admin-2.js}"></script>

    <!-- datatables  JavaScript -->
    <script th:src="@{/vendor/datatables/js/jquery.dataTables.min.js}"></script>

    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>


    <script type="text/javascript">
        function newInsert() {
            $("#insertForm").show();
            $("#updateForm").hide();
        }
        ;

        function deleteOne() {
            var deleteId = $("#UID").val();
            $.ajax({
                type: "POST",
                url: "/creditInfoDelete",
//                dataType: "json",
                data: {
                    deleteId: deleteId
                },
                success: function (data) {
                    alert("删除成功，将自动刷新记录");
                    $("#updateForm").submit();
                }
            });
        }

        $(document).ready(function () {
            var table = $('#dataTables-example').DataTable(
                {
                    "scrollY": "200px",    //设置Y轴长度和拖动条
                    "scrollCollapse": "true",

                    "language": {    //设置中文表格提示语
                        "lengthMenu": "每页 _MENU_ 条记录",
                        "zeroRecords": "没有找到记录",
                        "info": "第 _PAGE_ 页 ( 总共 _PAGES_ 页 )",
                        "infoEmpty": "无记录",
                        "infoFiltered": "(从 _MAX_ 条记录过滤)"
                    },
                    "columnDefs": [ // 表格设置隐藏 其他机构名称 & 其他机构评级&id 3列
                        {
                            "targets": [5],
                            "visible": false,
                            "searchable": false
                        },
                        {
                            "targets": [6],
                            "visible": false,
                            "searchable": false
                        },
                        {
                            "targets": [7],
                            "visible": false,
                            "searchable": false
                        }
                    ]


                }
            );


            $('#dataTables-example tbody').on('click', 'tr', function () {

                var data = table.row(this).data();
                $("#insertForm").hide();
                $("#updateForm").show();
                $("#Uline_no").val(data[0]);
                $("#URating").val(data[1]);
                $("#UOtherOrgName").val(data[5]);
                $("#UOtherOrgeRating").val(data[6]);
                $("#UHaveBadRecord").val(data[2]);
                $("#UTotalSecurityCCY").val(data[3]);
                $("#UTotalSecurity").val(data[4]);
                $("#UID").val(data[7]);

//                alert('You clicked on ' + data[0] + '\'s row');

            });


        });


    </script>


</head>
<body>
<div id="creditInfo">
    <div class="col-lg-12">
        <form id="insertForm" th:action="@{/creditInfo(custcode=${custcode})}" th:object="${creditInfo_entity_insert}"
              method="post">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-lg-4">
                            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">新增信用信息</a>
                            <button type="submit" class="btn btn-primary">添 加</button>

                        </div>

                    </div>

                </div>
                <div id="collapseOne" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label id="eduhao">额度号：</label>
                                </div>
                                <div class="col-lg-4">
                                    <input class="form-control" th:field="*{line_no}" name="line_no " maxlength="5"
                                           required>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>我行信用评级等级：</label>
                                </div>
                                <div class="col-lg-4">
                                    <input class="form-control" th:field="*{Rating}" name="Rating" maxlength="6"
                                           required>
                                </div>
                            </div>
                            <div class="col-lg-6">
                            </div>


                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>其他机构名称：</label>
                                </div>
                                <div class="col-lg-8">
                                    <input class="form-control" th:field="*{OtherOrgName}" name="OtherOrgName"
                                           maxlength="20">
                                </div>
                            </div>
                            <br/>
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>其他机构评级：</label>
                                </div>
                                <div class="col-lg-4">
                                    <input class="form-control" th:field="*{OtherOrgeRating}" name="OtherOrgeRating"
                                           maxlength="6">
                                </div>
                            </div>

                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>征信系统是否有不良记录：</label>
                                </div>

                                <div class="col-lg-4">
                                    <select class="form-control" th:field="*{HaveBadRecord}" name="HaveBadRecord"
                                            REQUIRED>
                                        <option disabled selected value>-</option>
                                        <option value="0">否</option>
                                        <option value="1">是</option>

                                    </select>
                                </div>

                            </div>
                        </div>
                        <br/>
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>目前对外担保总额：</label>
                                </div>

                                <div class="col-lg-4">
                                    <select class="form-control" th:field="*{TotalSecurityCCY}" required>
                                        <!--<option value="rmb">CNY</option>-->
                                        <!--<option value="USD">USD</option>-->
                                        <option th:each="Type:${creditInfo_info.CCYList}" th:value="${Type.CCY}"
                                                th:text="${Type.CCY}"></option>

                                    </select>
                                </div>
                                <div class="col-lg-4">
                                    <input class="form-control" th:field="*{TotalSecurity}" name="TotalSecurity"
                                           type="number" min="0" maxlength="12" required>
                                </div>


                            </div>

                        </div>

                    </div>
                </div>
            </div>


        </form>

        <form id="updateForm" th:action="@{/creditInfoUpdate(custcode=${custcode})}"
              th:object="${creditInfo_entity_update}" method="post" style="display:none">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-lg-4">
                            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">修改信用信息</a>
                            <button type="submit" class="btn btn-primary">更 新</button>
                            <!--<button id="deleteButton" type="button" class="btn btn-primary" th:onclick="'javascript:deleteOne(\''+*{ID}+'\');'" >删 除</button>-->
                            <button type="button" class="btn btn-primary" th:onclick="'deleteOne()'">删 除</button>

                            <!--<a  role="button" data-toggle="modal" th:onclick="'javascript:deleteOne('+${creditInfo_entity_update.ID}+');'">修改</a>-->
                        </div>

                    </div>

                </div>
                <div id="collapseThree" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>额度号：</label>
                                </div>
                                <div class="col-lg-4">
                                    <input class="form-control" th:field="*{line_no}" id="Uline_no" maxlength="5"
                                           disabled required>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>我行信用评级等级：</label>
                                </div>
                                <div class="col-lg-4">
                                    <input class="form-control" th:field="*{Rating}" ID="URating" maxlength="6"
                                           required>
                                </div>
                            </div>
                            <div class="col-lg-6">
                            </div>


                        </div>

                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>其他机构名称：</label>
                                </div>
                                <div class="col-lg-8">
                                    <input class="form-control" th:field="*{OtherOrgName}" ID="UOtherOrgName"
                                           maxlength="20">
                                </div>
                            </div>
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>其他机构评级：</label>
                                </div>
                                <div class="col-lg-4">
                                    <input class="form-control" th:field="*{OtherOrgeRating}" ID="UOtherOrgeRating"
                                           maxlength="6">
                                </div>
                            </div>

                        </div>

                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>征信系统是否有不良记录：</label>
                                </div>
                                <div class="col-lg-8">
                                    <div class="col-lg-4">
                                        <select class="form-control" th:field="*{HaveBadRecord}" ID="UHaveBadRecord"
                                                REQUIRED>
                                            <option disabled selected value>-</option>
                                            <option value="0">否</option>
                                            <option value="1">是</option>

                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-4">
                                    <label>目前对外担保总额：</label>
                                </div>
                                <div class="col-lg-8">
                                    <div class="col-lg-4">
                                        <select ID="UTotalSecurityCCY" class="form-control"
                                                th:field="*{TotalSecurityCCY}" required>
                                            <!--<option value="rmb">CNY</option>-->
                                            <!--<option value="USD">USD</option>-->
                                            <option th:each="Type:${creditInfo_info.CCYList}" th:value="${Type.CCY}"
                                                    th:text="${Type.CCY}"></option>

                                        </select>
                                    </div>
                                    <div class="col-lg-8">
                                        <input class="form-control" th:field="*{TotalSecurity}" id="UTotalSecurity"
                                               type="number" min="0" maxlength="12" required>
                                    </div>

                                </div>
                            </div>

                        </div>

                        <div class="row" style="display:none">

                            <div class="col-lg-6">
                                <input class="form-control" th:field="*{ID}" ID="UID" maxlength="6">
                            </div>
                        </div>

                    </div>
                </div>
            </div>


        </form>

        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-lg-4">
                        <button type="button" class="btn btn-primary" onclick="newInsert()">新 增</button>
                        <a th:href="@{/creditInfo(custcode=${custcode})}">
                            <button type="button" class="btn btn-primary">刷 新</button>
                        </a>
                    </div>

                </div>

            </div>
            <div id="collapseTwo" class="panel-collapse collapse in">
                <div class="panel-body">
                    <div class="row">
                        <div class="tableinfo">
                            <table id="dataTables-example" class="row-border hover order-column" cellspacing="0"
                                   width="100%">
                                <thead>
                                <tr>
                                    <th>额度号</th>
                                    <th>我行信用评级等级</th>
                                    <th>征信系统是否有不良记录</th>
                                    <th>目前对外担保总额币种</th>
                                    <th>目前对外担保总额</th>
                                    <th>其他机构名称</th>
                                    <th>其他机构评级</th>
                                    <th>ID</th>
                                </tr>
                                </thead>
                                <!--<tfoot>-->
                                <!--<tr>-->
                                <!--<th>额度号</th>-->
                                <!--<th>我行信用评级等级</th>-->
                                <!--<th>征信系统是否有不良记录</th>-->
                                <!--<th>目前对外担保总额币种</th>-->
                                <!--<th>目前对外担保总额</th>-->
                                <!--</tr>-->
                                <!--</tfoot>-->
                                <tbody id="creditInfoTable">
                                <tr th:each="creditInfo:${creditInfo_info.criditInfoList}">
                                    <td th:text="${creditInfo.LINE_NO}"></td>
                                    <td th:text="${creditInfo.RATING}"></td>
                                    <td th:text="${creditInfo.HAVEBADRECORD}"></td>
                                    <td th:text="${creditInfo.TOTALSECURITYCCY}"></td>
                                    <td th:text="${creditInfo.TOTALSECURITY}"></td>
                                    <td th:text="${creditInfo.OTHERORGNAME}"></td>
                                    <td th:text="${creditInfo.OTHERORGERATING}"></td>
                                    <td th:text="${creditInfo.ID}"></td>
                                </tr>
                                </tbody>

                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

</div>


</body>
</html>